﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DP.Data.Common;
using DP.Data.OracleClient;
using DP.Data.SqlClient;
using System.Configuration;

namespace CRM.BLL
{
    public class DALFactory
    {
        public static DAL<T> CreateDal<T>()
        {
            string DataSourceType = string.Empty;
            try
            {
                DataSourceType = ConfigurationManager.AppSettings["DataSourceType"].ToString();
            }
            catch (Exception ex)
            {
            }
            DAL<T> dal = null;
            switch (DataSourceType)
            {
                case "Oracle":
                    {
                        dal = new OracleDAL<T>();
                    }
                    break;
                case "SqlServer":
                    {
                        dal = new SqlServerDAL<T>();
                    }
                    break;
                default:
                    {

                    }
                    break;
            }
            dal.IsDebugLog = true;
            
            return dal;
        }
    }
}
